package com.shop.milk_tea_shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.shop.milk_tea_shop.entity.ItemAdd;
import com.shop.milk_tea_shop.mapper.ItemAddMapper;
import com.shop.milk_tea_shop.request.ItemAddsQueryRequest;
import com.shop.milk_tea_shop.service.ItemAddService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品附加信息表 服务实现类
 * </p>
 *
 * @author yjw
 * @since 2024-06-16
 */
@Service
public class ItemAddServiceImpl extends ServiceImpl<ItemAddMapper, ItemAdd> implements ItemAddService {

    @Autowired
    ItemAddMapper itemAddMapper;

    @Override
    public List<ItemAdd> getMenu(ItemAddsQueryRequest request) {
        LambdaQueryWrapper<ItemAdd> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(request.getAddId() != null, ItemAdd::getAddId, request.getAddId());
        queryWrapper.like(StringUtils.isNotBlank(request.getAddName()), ItemAdd::getAddName, request.getAddName());
        queryWrapper.eq(request.getStatus() != null, ItemAdd::getStatus, request.getStatus());
        return itemAddMapper.selectList(queryWrapper);
    }
}
